<template>
  <!-- 设备调拨记录 -->
  <div class="allocation-record-con">
    <a-card :bordered="false">
      <title-name :title="title"></title-name>
      <b-table ref="table" bordered :columns="columns" :request="recordTableData" row-key="id">
        <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
      </b-table>
    </a-card>
  </div>
</template>

<script>
import api from '@/api/quality/ownEquipmentLedger' // api
export default {
  name: "allocationRecord",
  props: {
    title: {
      type: String,
      default() {
        return '设备调拨记录'
      }
    },
    // api请求方法
    apiName: {
      type: String,
      default: () => 'getEquipmentAllocationRecord'
    },
    //查询参数
    queryParam: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      api,
      columns: [
        {
          title: '序号',
          dataIndex: 'serial',
          scopedSlots: { customRender: 'serial' },
          width: 70
        },
        {
          title: '所在项目',
          dataIndex: 'projectName'
        },
        {
          title: '进场时间',
          dataIndex: 'entranceTime'
        },
        {
          title: '退场时间',
          dataIndex: 'exitTime'
        },
      ],
      recordTableData: async (parameter) => {
        let { pageNo, pageSize } = parameter;
        let params = {
          pageNum: pageNo,
          pageSize
        };
        const requestParameters = Object.assign({}, params, { param: this.queryParam })
        return this.api[this.apiName](requestParameters).then((res) => {
          if (res.code === '0') {
            return { code: 200, data: res.data?.list, totalSize: res.data?.total }
          }
        })
      },
    }
  }
}
</script>